<template>
  <div class="">
    <h1>首页 hello Word</h1>
    <h1 v-if="msg.account != ''">你当前账号是{{ msg.account }}</h1>
    <AppButton text="退出登录" @click.native="backLogin"></AppButton>
  </div>
</template>

<script>
import AppButton from "../components/appButton.vue";
export default {
  data() {
    return {
      msg: JSON.parse(localStorage.getItem("token")) || [],
    };
  },
  mounted() {},
  methods: {
    backLogin() {
      let flag = confirm("确定退出登录");
      if (flag) {
        localStorage.removeItem("token");
        this.$router.push({ path: "login" });
      } else {
        console.log(1);
      }
    },
  },
  components: { AppButton },
};
</script>

<style lang="scss" scoped></style>
